
//------------------------------------------------------------------------------

using Apps.Models;
using Apps.IDAL.CY;
using System;
using System.Linq;

namespace Apps.DAL.CY
{
    public partial class CY_INSTOCKRepository : BaseRepository<CY_INSTOCK>, ICY_INSTOCKRepository, IDisposable
    {
        public CY_INSTOCKRepository(DBContainer db) : base(db)
        {

        }

        public override bool Delete(CY_INSTOCK model)
        {
            return base.Delete(model);
        }

        public IQueryable<CY_INSTOCKModel> QueryList()
        {
            var result = from a in Context.CY_INSTOCK
                         join b in Context.SysUser on a.INSTOCK_USER equals b.UserName into tbs
                         from tb in tbs.DefaultIfEmpty()
                         select new CY_INSTOCKModel()
                         {
                             COALYARD_AMOUNT = a.COALYARD_AMOUNT,
                             INSTOCK_DATE = a.INSTOCK_DATE,
                             INSTOCK_ID = a.INSTOCK_ID,
                             INSTOCK_TIME = a.INSTOCK_TIME,
                             INSTOCK_USER = a.INSTOCK_USER,
                             OTHER_AMOUNT = a.OTHER_AMOUNT,
                             TOTAL = a.TOTAL,
                             INSTOCK_USERName = tb.TrueName
                         };

            return result;
        }
    }
}
